<?php
namespace Admin\Controller;
use Admin\Controller\CommonController;
class MenuController extends CommonController {
 
  //===================================产品订单
    public function index() {
         header("Content-Type:text/html; charset=utf-8");
        if(IS_POST){
        $tel=I('post.tel');

        $or=M('order');
        $map['tel']=$tel;    
        $menu=$or->where($map)->order('id desc')->select();
           
        $this->assign('menu',$menu);


        }else{

        $User = M('order'); // 实例化User对象
        $count = $User->count();// 查询满足要求的总记录数
        $Page = new \Think\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show = $Page->show();// 分页显示输出
        // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $list = $User->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('menu',$list);// 赋值数据集
        $this->assign('page',$show);// 赋值分页输出

        }



        $this->display();
    }



public function yijian(){

               $count = M('fankui')->count();
               
  
        $Page =new \Think\Page($count,20);
        $Page -> setConfig('first','首页');
        $Page -> setConfig('last','末页');
        $Page -> setConfig('prev','上一页');
        $Page -> setConfig('next','下一页');
        $Page -> setConfig('theme',' <div style="margin-top:2px">  %FIRST%  %UP_PAGE%    %LINK_PAGE%  %DOWN_PAGE%   %END% </div> ');

         
        $show = $Page->show();
       

$data=M('fankui')->alias('a')->field('a.id,a.fankui,a.userid,b.phone,b.user as name')->join("zyb_user b on b.id=a.userid")->limit($Page->firstRow.','.$Page->listRows)->select();
$this->assign('count',$count);
$this->assign('page',$show);
$this->assign('data',$data);
   $this->display();

}


public function del(){

        $ids = $_POST['id'];


      
        $str="('".implode("','",$ids)."')";
    
      

    
        if (M("fankui")->where("id in ".$str)->delete()) {
            
            $this->success('删除成功');
        } else {
            $this->success('删除失败');
        }
    }



    
    public function delAdmin(){
        
        $id=I('get.id');
        M('order')->where(array('id'=>$id))->delete();
        $this->success('删除成功');

    }
    
        

    public function three()  {


        $menu1=M('zixun')->select();
        $this->assign("menu1",$menu1);
        $this->display();

    }

    public function adddate(){

        $id=I('id');
        $id=M('order')->where('id='.$id)->find();
        $this->assign('id',$id);
     
        $state=M('state')->select();
        $this->assign('state',$state);
       
        if(IS_POST){
            $data['endtime']=strtotime(I('post.endtime'));
            $data['xendtime']=strtotime(I('post.xendtime'));
            $data['baotime']=strtotime(I('post.baotime'));
            $data['state']=I('post.state');
            $data['id']=I('post.id');

        if(M('order')->where(array('id'=>$data['id']))->save($data)){
            $this->success('订单处理成功',U('Menu/index'));
            exit();
        }else{
            $this->success('订单处理失败',U('Menu/index'));
            exit();
        }    


        }

        $this->display();
    }




    
}

?>